//
//  FullNormalListViewController.m
//  tangshantongjiAPPFull
//
//  Created by yuntai on 2018/4/20.
//  Copyright © 2018年 yuntai. All rights reserved.
//

#import "FullNormalListViewController.h"
#import "FullMainModel.h"
#import "NewsListViewController.h"
#import "ZaiXianZhengJiViewController.h"
#import "PhoneListViewController.h"

@interface FullNormalListViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic ,strong)NSMutableArray *array;
@property (nonatomic, strong) UITableView *tableview;

@end

@implementation FullNormalListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.array = [NSMutableArray array];
    UITableView *tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, kNavigationHeight, kScreenBoundWidth, kScreenBoundHeight-kNavigationHeight-45) style:UITableViewStylePlain];
    tableview.delegate = self;
    tableview.dataSource = self;
    tableview.rowHeight = 66;
    tableview.sectionHeaderHeight = 30;
    tableview.tableFooterView = [[UIView alloc]init];
    [tableview setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.tableview = tableview;
    [self.view addSubview:tableview];
    
    if(self.type == FullTongJiShuJu){
        NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计月报",@"name",@"tongjiyuebao",@"image", nil];
        NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计分析",@"name",@"tongjifenxi",@"image",nil];
        NSDictionary *dic3 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计公报",@"name",@"tongjigongbao",@"image", nil];
        NSDictionary *dic4 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计提要",@"name",@"tongjitiyao",@"image", nil];
        NSDictionary *dic5 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计年鉴",@"name",@"tongjinianjian",@"image", nil];
        NSDictionary *dic6 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计图标",@"name",@"tongjibiaozhun",@"image", nil];
                              
        [self.array addObject:dic1];
        [self.array addObject:dic2];
        [self.array addObject:dic3];
        [self.array addObject:dic4];
        [self.array addObject:dic5];
        [self.array addObject:dic6];

    }else if (self.type == FullTongJiZhiShi){
        NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计标准",@"name",@"tongjibiaozhun",@"image",nil];
        NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"指标解释",@"name",@"tongjitubiao",@"image",nil];
        NSDictionary *dic3 = [NSDictionary dictionaryWithObjectsAndKeys:@"统计制度",@"name",@"tongjizhidu",@"image", nil];
        [self.array addObject:dic1];
        [self.array addObject:dic2];
        [self.array addObject:dic3];
    }else if (self.type == FullYongHuXuQiu){
        NSDictionary *dic1 = [NSDictionary dictionaryWithObjectsAndKeys: @"在线征集", @"name",@"zaixianzhengji",@"image", nil];
        NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"电话专业咨询",@"name",@"dianhuazixun",@"image", nil];
        [self.array addObject:dic1];
        [self.array addObject:dic2];
    }
    
    BOOL ishow = self.array.count ? NO : YES;
    [self.tableview showNoView:nil image:nil certer:CGPointZero isShow:ishow];
    [self.tableview reloadData];
}

#pragma mark tableviewdelegate datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.array.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *pricecellid = @"pricevideocellid";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:pricecellid];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:pricecellid];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 66-0.7, kScreenBoundWidth, 0.7)];
        line.backgroundColor = KSepLineColor;
        [cell.contentView addSubview:line];
        cell.textLabel.textColor = kTextDeepDarkColor;
        cell.textLabel.font = [UIFont systemFontOfSize:15];
        
        UIImageView *yuanview = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15.5, 35, 35)];
        yuanview.layer.cornerRadius = 4;
        yuanview.layer.masksToBounds = YES;
        yuanview.tag = 100;
        [cell.contentView addSubview:yuanview];
        
        UILabel *namel = [[UILabel alloc]initWithFrame:CGRectMake(60, 0, kScreenBoundWidth-80, 66)];
        namel.tag = 101;
        namel.textColor = kTextDeepDarkColor;
        namel.font = [UIFont boldSystemFontOfSize:16];
        [cell.contentView addSubview:namel];
        
       
        
    }
    NSDictionary *dic = self.array[indexPath.section];
    
    UILabel *namel = [cell.contentView viewWithTag:101];
    namel.text = dic[@"name"];
    
    UIImageView *imageview = [cell.contentView viewWithTag:100];
    imageview.image = [UIImage imageNamed:dic[@"image"]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    NSDictionary *model = self.array[indexPath.section];
    NSDictionary *dic = self.array[indexPath.section];

    if (self.type == FullYongHuXuQiu){
        /**用户需求*/
        if(indexPath.section == 0){
            /**在线征集*/
            ZaiXianZhengJiViewController *vc = [[ZaiXianZhengJiViewController alloc]init];
            vc.title = dic[@"name"];
            [self.navigationController pushViewController:vc animated:YES];
        }else{
            /**电话咨询*/
            PhoneListViewController *vc = [[PhoneListViewController alloc]init];
            vc.title = dic[@"name"];
            [self.navigationController pushViewController:vc animated:YES];

        }
        
        return;
    }
    NewsListViewController *vc = [[NewsListViewController alloc]init];
    if(self.type == FullTongJiShuJu){
        vc.type = indexPath.section+7;
    }else if (self.type == FullTongJiZhiShi){
         vc.type = indexPath.section+13;
    }
    vc.title = dic[@"name"];
    [self.navigationController pushViewController:vc animated:YES];
    
}


@end
